package logical;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.junit.Test;

import junit.*;

public class teste {

	boolean first=true;
	
	public boolean geraResultado(String regex)
	{
		String name = new String(regex);
		name=name+'\n';
		InputStream input = new ByteArrayInputStream(name.getBytes());
		boolean a=false;;
		 try
		 {
			
			 
			if(first)
				new AutomataGenerator(input);
			 else
				 logical.AutomataGenerator.ReInit(input);
			first=false;
			SimpleNode n = logical.AutomataGenerator.Start();
			
			 a=true;
		 }catch(Exception e)
		 {
			 first=true;
			 a=false;
		 }
		
		 return a;
	}
	@Test
	public void test1() {
		assertEquals(true, geraResultado("a*"));
		
	}
	
	@Test
	public void test2() {
		assertEquals(false, geraResultado("1"));
		
	}
	@Test
	public void test3() {
		assertEquals(false, geraResultado("-"));
		
	}
	@Test
	public void test4() {
		assertEquals(true, geraResultado("a*b*c{1,2}(a+c)*"));
		
	}
	

	

}
